<template>
<div>
  贴文审核
  <table>
    <tr>
      <th>贴文Id<th>发布者Id</th><th>内容</th><th>发布时间</th><th>是否审核</th><th>操作</th>
    </tr>
    <tr v-for="item in posts" :key="item.id">
      <td>{{item.id}}</td><td>{{item.upId}}</td><td>{{item.content}}</td><td>{{item.upTime}}</td><td>{{item.approved}}</td><td><Button @click="check(item.id)">审核</Button></td>
    </tr>
  </table>
</div>
</template>

<script>
export default {
  name: "postCheck",
  data(){
    return{
      posts:[]
    }
  },
  methods:{
    check(id){
      let params = new URLSearchParams()
      params.append('approve','1')
      // params.append('managerId',sessionStorage.getItem('userId'))
      params.append('postId',id)

      this.$http.post('/api/checkPost',params).then(res=>{
        if(res.data.code === 200){
          this.$Message.success('操作成功')
        }
      })

    },

  },
  created(){
    //获取所有未审核贴文
    this.$http.get('/api/getPostWithoutCheck').then(res=>{
      if(res.data.code === 200){
        this.posts = res.data.data.Posts
      }
    }).catch(error=>{
      console.log(error)
    })
  },

}
</script>

<style scoped>

</style>
